<!DOCTYPE html>
<html>
  
  <head>
    <meta charset="UTF-8">
    <title>NormalSystem</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width,user-scalable=yes, minimum-scale=0.4, initial-scale=0.8,target-densitydpi=low-dpi" />
    <link rel="shortcut icon" href="/favicon.ico" type="image/x-icon" />
    <link rel="stylesheet" href="./css/font.css">
    <link rel="stylesheet" href="./css/xadmin.css">
    <script type="text/javascript" src="./lib/layui/layui.js" charset="utf-8"></script>
      <script type="text/javascript" src="./js/jquery.js"></script>
    <script type="text/javascript" src="./js/xadmin.js"></script>
    <script type="text/javascript" src="./js/project.js"></script>
  </head>
  
  <body>
    <div class="x-body">
        <form class="layui-form" lay-filter="projectForm">
          <input type="hidden" id="code" name="code" />
          <div class="layui-form-item">
              <label for="cnName" class="layui-form-label">
                  <span class="x-red">*</span>项目名称
              </label>
              <div class="layui-input-inline">
                  <input type="text" id="cnName" name="cnName" required="" lay-verify="required"
                  autocomplete="off" class="layui-input">
              </div>
              <div class="layui-form-mid layui-word-aux">
                  <span class="x-red">*</span>
              </div>
          </div>

            <div class="layui-form-item">
                <label for="name" class="layui-form-label">
                    <span class="x-red"></span>项目名称(英)
                </label>
                <div class="layui-input-inline">
                    <input type="text" id="name" name="name" required=""
                           autocomplete="off" class="layui-input">
                </div>
                <div class="layui-form-mid layui-word-aux">
                    <span class="x-red"></span>
                </div>
            </div>

            <div class="layui-form-item">
                <label for="dbAddr" class="layui-form-label">
                    <span class="x-red"></span>数据库地址
                </label>
                <div class="layui-input-inline">
                    <input type="text" id="dbAddr" name="dbAddr" required=""
                           autocomplete="off" class="layui-input">
                </div>
                <div class="layui-form-mid layui-word-aux">
                    <span class="x-red"></span>
                </div>
            </div>

            <div class="layui-form-item">
                <label for="dbPort" class="layui-form-label">
                    <span class="x-red"></span>数据库端口
                </label>
                <div class="layui-input-inline">
                    <input type="text" id="dbPort" name="dbPort" required=""
                           autocomplete="off" class="layui-input">
                </div>
                <div class="layui-form-mid layui-word-aux">
                    <span class="x-red"></span>
                </div>
            </div>

            <div class="layui-form-item">
                <label for="dbUserName" class="layui-form-label">
                    <span class="x-red"></span>数据库账号
                </label>
                <div class="layui-input-inline">
                    <input type="text" id="dbUserName" name="dbUserName" required=""
                           autocomplete="off" class="layui-input">
                </div>
                <div class="layui-form-mid layui-word-aux">
                    <span class="x-red"></span>
                </div>
            </div>

            <div class="layui-form-item">
                <label for="dbPwd" class="layui-form-label">
                    <span class="x-red"></span>数据库密码
                </label>
                <div class="layui-input-inline">
                    <input type="text" id="dbPwd" name="dbPwd" required=""
                           autocomplete="off" class="layui-input">
                </div>
                <div class="layui-form-mid layui-word-aux">
                    <span class="x-red"></span>
                </div>
            </div>

            <div class="layui-form-item">
                <label for="name" class="layui-form-label">
                    <span class="x-red"></span>端口号
                </label>
                <div class="layui-input-inline">
                    <input type="text" id="port" name="port" autocomplete="off" class="layui-input">
                </div>
                <div class="layui-form-mid layui-word-aux">
                    <span class="x-red"></span>
                </div>
            </div>
          <div class="layui-form-item">
              <button id="saveProjectBtn" class="layui-btn" lay-filter="addProject" lay-submit="">
                  保存
              </button>
          </div>
      </form>
    </div>
    <script>
        // var url = location.href;
        // var paraString = url.substring(url.indexOf("?") + 1, url.length);
        var str=location.href; //取得整个地址栏
        var num=str.indexOf("?")
        str=str.substr(num+1); //取得所有参数   stringvar.substr(start [, length ]
        var arr=str.split("&"); //各个参数放到数组里
        var detail = decodeURI(arr[1].substr(arr[1].indexOf("=")+1)),code = arr[0].substr(arr[0].indexOf("=")+1);

        var obj = new Object();
        obj.code = code;
        $.ajax({
            url          : localStorage.getItem("url")+'code-generator/project/detail',
            method       : 'POST',
            contentType  : 'application/json',
            dataType     : 'json',
            headers      : {"token" : localStorage.getItem("token")},
            data         : JSON.stringify(obj),
            success      : function (res) {
                if(res.code == 100000) {
                    $("#code").val(res.data.code);
                    $("#name").val(res.data.name);
                    $("#cnName").val(res.data.cnName);
                    $("#dbAddr").val(res.data.dbAddr);
                    $("#dbPort").val(res.data.dbPort);
                    $("#dbUserName").val(res.data.dbUserName);
                    $("#dbPwd").val(res.data.dbPwd);
                    $("#port").val(res.data.port);

                    if(detail == 1) {
                        $("#saveProjectBtn").addClass("layui-hide")
                    }
                } else {
                    layer.msg(res.msg);
                }
            }
        })

    </script>
  </body>

</html>